﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading.Tasks;

namespace LawSuitUploadTask
{
    class OperateIniFile
    {
        private OperateIniFile() { }

        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

        [DllImport("kernel32")]//返回取得字符串缓冲区的长度
        private static extern long GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);


        //读取ini文件
        public static string ReadIniData(string Section, string Key, string iniFilePath)
        {
            StringBuilder temp = new StringBuilder(8192000);
            GetPrivateProfileString(Section, Key, "null", temp, 8192000, iniFilePath);
            return temp.ToString();
        }

        public static void WriteIniData(string section, string key, string value, string filePath)
        {
            WritePrivateProfileString(section, key, value, filePath);
        }

    }
}
